package com.rsscollector.controller.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.log4j.Logger;

import com.rsscollector.util.PersistenceUtil;

public class StartupServletContextListener implements ServletContextListener {

	private static Logger logger = Logger
			.getLogger(StartupServletContextListener.class.getName());
    
    public void contextDestroyed(ServletContextEvent sce) {
		logger.info("Destroying " + sce.getServletContext().getServletContextName() + " application context ...");
        PersistenceUtil.destroy();
		logger.info("Completed destroying " + sce.getServletContext().getServletContextName() + " application context ...");
	}

	public void contextInitialized(ServletContextEvent sce) {
		logger.info("Initializing " + sce.getServletContext().getServletContextName() + " application context ...");
		PersistenceUtil.init();
		logger.info("Completed initializing " + sce.getServletContext().getServletContextName() + " application context ...");
	}

}
